package com.example.wanglv;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;
import java.util.Map;

public class MyAdpater extends BaseAdapter {
    Context context;
    List<Map<String,String>>mapList;

    public MyAdpater(Context context, List<Map<String, String>> mapList) {
        this.context = context;
        this.mapList = mapList;
    }

    @Override
    public int getCount() {
        return 3;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView==null){
            viewHolder=new ViewHolder();
            convertView= LayoutInflater.from(context).inflate(R.layout.list_item,null);
            viewHolder.money = convertView.findViewById(R.id.money);
            viewHolder.tv_name1= convertView.findViewById(R.id.tv_names);
            convertView.setTag(viewHolder);
        }else {
            viewHolder=(ViewHolder) convertView.getTag();
        }
        Map<String,String>map=mapList.get(position);
        viewHolder.tv_name1.setText(map.get("name"));
        viewHolder.money.setText(map.get("money"));
        return convertView;
    }
    class ViewHolder{
        TextView money;
        TextView tv_name1;
    }
}
